﻿@using si.caha.Helper;

@{
    var cartItemsCount = 0;
    if(Validator.isCookieFilled(Request.Cookies))
    {
        cartItemsCount = Request.Cookies["cart"]["items"].Split(',').Count();
        @ObjectInfo.Print("Cookie: " + Request.Cookies["cart"]["items"]);
    }
}

<div id="home">
    <a href="@Href("~")">Home</a>
</div>
<div id="navigation">
    @foreach (var url in Navigator.GetNavigationUrls(Request.Url.ToString()))
    {
        <span>&gt;</span>
        <a href="@Href(url["Url"])">@url["Title"]</a>
    }
</div>
<div class="cart">
    <a href="@Href("~/Cart")">My cart(<span id="cartItemsCount">@cartItemsCount</span>)</a>
</div>
<div id="logindisplay">
@if (WebSecurity.IsAuthenticated)
{
    <span>
    Logged in as <b><a href="@Href("~/Account")">@WebSecurity.CurrentUserName</a></b>
    [ <a href="@Href("~/Account/Logout")">Logout</a> ]
    @if (Roles.IsUserInRole("admin")) 
    {
        <a href="@Href("~/Admin")">Admin page</a>
    }
    </span>
} 
else 
{
    <span>[ <a href="@Href("~/Account/Login")">Login</a> | <a href="@Href("~/Account/Register")">Register</a> ]</span>
}
</div>
<h1>@PageData["PageTitle"]</h1>
